package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;

public class SQRT extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Object localObject = paramArrayOfObject[0];
    if (localObject instanceof Number)
      return new Double(Math.sqrt(((Number)localObject).doubleValue()));
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "SQRT(number): 返回一个正数的平方根。\nNumber:要求其平方根的任一正数。\n备注:\nNumber必须是一个正数，否则函数返回错误信息*NUM!。\n示例:\nSQRT(64)等于8。\nSQRT(-64)返回*NUM!。";
  }

  public String getEN()
  {
    return "SQRT(number): Returns a positive square root.\nNumber is the number for which you want the square root.\n\nRemarks:\n   If number is negative, SQRT returns the #NUM! error value.\n\nExample:\n   SQRT(64) = 8\n   SQRT(-64) returns *NUM!";
  }
}